package aima.search;

import java.lang.*;
import java.util.*;

/**
   This class implements an iterative deepening search.
*/ 


public class IteratedDeepeningSearch implements SearchMethod {

  /** Start state, which must be stored to implement repeated searches. */
   State startState;  

  /* Constructor takes starting state */
   public IteratedDeepeningSearch(State startState) {
       this.startState = startState;
   }

  /* Implementation of iterated deepening search. */
   public SearchNode search() {
 
       for (int depth=1 ; ; depth++) {
          SearchNode node 
                = (new DepthBoundedSearch(startState, depth)).search();
       
          if (node != null) return node;                            
       }
   } 

}

